package router

// by daoyi
import (
	"github.com/gin-gonic/gin"
	"simai_oa/controller/api"
	"simai_oa/middlewares"
)

func ApiRoutesInit(r *gin.Engine) {
	//登陆获取token
	r.GET("/login", api.UserBasicController{}.Login)               //用户登陆页
	r.GET("/register", api.UserBasicController{}.Register)         //用户登陆页
	r.POST("/api/user/login", api.UserBasicController{}.UserLogin) //用户登陆
	//user导出excel
	r.GET("/api/user/toweb", api.GetAllUserExportToWeb)
	r.GET("/api/user/export", api.GetUserExcelByMap) //excel导出
	//路由分组
	apiRoutes := r.Group("/api")
	//中间件 包含jwt中间件
	apiRoutes.Use(middlewares.JWThMiddlewareApi())
	{
		//聊天室
		apiRoutes.GET("/chat/home", api.UserBasicController{}.Home)

		//user管理
		apiRoutes.GET("/user/index", api.UserBasicController{}.Index)
		apiRoutes.GET("/user/getall", api.UserBasicController{}.GetAll)
		apiRoutes.POST("/user/create", api.UserBasicController{}.CreateUser)
		apiRoutes.POST("/user/update", api.UserBasicController{}.UpdateUser)
		apiRoutes.GET("/user/delete", api.UserBasicController{}.DeleteUser)

		//websocket请求
		apiRoutes.GET("/socket/sendmsg", api.WebsocketController{}.SendMsg)
		//发送消息给指定的用户
		apiRoutes.GET("/socket/sendusermsg", api.WebsocketController{}.SendUserMsg)

		apiRoutes.POST("/user/searchFriends", api.UserBasicController{}.SearchFriends)

		apiRoutes.POST("/show", func(c *gin.Context) {
			c.String(200, "你好我是显示show123456")
		})

	}
}
